<%@page import="bc.swim2.ejb.entity.RegisteredUser"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	import="java.util.*,bc.swim2.ejb.entity.Ability"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script>
	function validateForm() {
		var abilityId = document.forms["fForm"]["selectedAbilityId"].value;
		var description = document.forms["fForm"]["description"].value;

		var nullFields = abilityId == null || description == null;

		var emptyFields = abilityId == "" || descritpion == "";

		if (nullFields || emptyFields) {
			alert("You must select an ability and write a comment!");
			return false;
		}
	}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Write feedback</title>
<style>
@import url(css/main.css);
</style>
</head>
<body>
	<div id="allContainer">
		<div id="titleContainer">
			<%
				RegisteredUser currentUser = (RegisteredUser) session
						.getAttribute("currentSessionUser");

				RegisteredUser profileUser = (RegisteredUser) session
						.getAttribute("profileUser");
			%>
			<img src="img/swimScritta.gif" id="imageFloat" width=100px;
				height="100px">
			<h1 id="userHomeTitle">
				Welcome,
				<%=currentUser.getFirstName() + " "
					+ currentUser.getLastName()%>!
			</h1>
		</div>
		<div id="container">
			<div id="navigationContainer">
				<a href="MainServlet?to=RegisteredUserHome" id="linkRef">Home</a> <br />
				<a href="MainServlet?to=SearchHelp" id="linkRef">Search Help</a> <br />
				<a href="MainServlet?to=SearchUsers" id="linkRef">Search Users</a> <br />
				<a href="MainServlet?to=MyAbilities" id="linkRef">Declare/Remove
					ability</a> <br /> <a href="MainServlet?to=FriendshipRequests"
					id="linkRef">Friendship Requests</a> <br /> <a
					href="MainServlet?to=Friends" id="linkRef">Your Friends</a> <br />
				<a href="MainServlet?to=MyFeedback" id="linkRef">Feedback</a> <br />
				<a href="MainServlet?to=AbilityRequest" id="linkRef">Ability
					Request</a> <br /> <a href="LoginServlet?methodName=logout"
					id="linkRef">Logout</a>
			</div>
			<div id="actionContainer">
				<h1 id="listTitle">
					Send your Feedback to
					<%=profileUser.getFirstName() + " "
					+ profileUser.getLastName()%></h1>
				<form id="writeFeedbackForm" name="fForm" action="FeedbackServlet"
					onsubmit="return validateForm();" method="post">
					<input type="radio" name="score" value="negative" checked>
					<font color="red">Bad</font> <input type="radio" name="score"
						value="positive"> <font color="green">Good</font><br>
					<br>
					<textarea name="description" onfocus="this.value=''" rows="3"
						cols="30"> Insert your comment here. MAX 1024 char!</textarea>

					<br> <br> <select name="selectedAbilityId" size="1">

						<%
							List<Ability> myAbilities = (List<Ability>) request
									.getAttribute("profileUserAbilities");

							Iterator<Ability> itb = myAbilities.iterator();

							while (itb.hasNext()) {

								Ability a = (Ability) (itb.next());
								int abilityId = a.getId();
								String abilityName = a.getName();

								out.println("<option value=" + abilityId + ">" + abilityName
										+ "</option>");
							}
						%>
					</select> <input type="submit" id="submitInputA" name="submit"
						value="Send Feedback" /> <input type="hidden" name="methodName"
						value="addFeedback" />



				</form>
			</div>
		</div>
	</div>
</body>
</html>